/*
 * PlistData.h
 *
 *  Created on: May 15, 2012
 *      Author: quyetnd
 */

#ifndef PLISTDATA_H_
#define PLISTDATA_H_

#include "cocos2d.h"

USING_NS_CC;
using namespace std;

class PlistData : public CCObject{
private :
	CCDictionary<string,CCObject*> *data;
	static CCDictionary<string,PlistData*> mapData;

	CCDictionary<string,CCObject*>* dictFromDict(const char *key, CCDictionary<string,CCObject*> *data);
	void tokenize(const string& str,vector<string>& tokens);
	void addDictToDict(CCObject* parent,CCObject* child,const char* key);
	void saveObjectToFile(FILE* file,CCObject* object);
public:
	PlistData();
	~PlistData();

	bool initFromFile(const char* file);
	bool initFromDict(CCObject* data);
	bool initFromPathFile(const char* path);
	void save(const char* path);

	static PlistData* getInstance(const char *file);
	static void removeInstance(const char *file);

	void set(const char* path, CCObject* object);
	CCObject* get(const char* path);

	int getInt(const char* path);
	float getFloat(const char* path);
	bool getBoolean(const char* path);

	void setInt(const char* path, int i);
	void setFloat(const char* path, float f);
	void setBoolean(const char* path, bool b);
};

#endif /* PLISTDATA_H_ */
